<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div>
      <button data-action="save">保存</button>
      <button data-action="del">删除</button>
      <button data-action="add">添加</button>
    </div>
    <script>
      function save() {
        console.log("保存");
      }
      function remove() {
        console.log("删除");
      }
      function add() {
        console.log("添加");
      }

      document.onclick = function (e) {
        const action = e.target.dataset.action;
        if (action === "del") {
          remove();
        }

        if (action === "add") {
          add();
        }

        if (action === "save") {
          save();
        }
      };
    </script>
  </body>
</html>
